namespace RBAC.Write.Api.Application.Dto
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// 创建生产工单命令 DTO。
    /// </summary>
    public class CreateWorkOrderCommandDto
    {
        // 基础信息
        public string OrderCode { get; set; } = string.Empty;
        public string OrderType { get; set; } = string.Empty;
        public DateTime OrderDate { get; set; }
        public string OrderStatus { get; set; } = "开立";
        public long? CustomerId { get; set; }
        public string? CustomerName { get; set; }
        public long ProductId { get; set; }
        public string ProductCode { get; set; } = string.Empty;
        public string ProductName { get; set; } = string.Empty;
        public string? Spec { get; set; }
        public string? Unit { get; set; }
        public decimal Quantity { get; set; }
        public DateTime? DeliveryDate { get; set; }
        public string? Priority { get; set; }
        public long? SalesPersonId { get; set; }
        public string? SalesPerson { get; set; }
        public string? BusinessType { get; set; }
        public string? Remark { get; set; }

        // BOM
        public List<CreateWorkOrderBomItemDto> BomItems { get; set; } = new();
        // 工序
        public List<CreateWorkOrderProcessDto> Processes { get; set; } = new();
        // 附件
        public List<CreateWorkOrderAttachmentDto> Attachments { get; set; } = new();
    }

    public class CreateWorkOrderBomItemDto
    {
        public long WorkOrderId { get; set; }
        public int LineNo { get; set; }
        public long MaterialId { get; set; }
        public string MaterialCode { get; set; } = string.Empty;
        public string MaterialName { get; set; } = string.Empty;
        public string? Spec { get; set; }
        public string? Unit { get; set; }
        public decimal Qty { get; set; }
        public decimal? LossRate { get; set; }
        public long? WarehouseId { get; set; }
        public string? WarehouseName { get; set; }
        public string? Remark { get; set; }
    }

    public class CreateWorkOrderProcessDto
    {
        public long WorkOrderId { get; set; }
        public int SeqNo { get; set; }
        public string ProcessCode { get; set; } = string.Empty;
        public string ProcessName { get; set; } = string.Empty;
        public long? WorkCenterId { get; set; }
        public string? WorkCenterName { get; set; }
        public decimal? StdHours { get; set; }
        public string? Uom { get; set; }
        public DateTime? PlanStartTime { get; set; }
        public DateTime? PlanEndTime { get; set; }
        public decimal? TransferQty { get; set; }
        public decimal? GoodQty { get; set; }
        public decimal? ScrapQty { get; set; }
        public decimal? WipQty { get; set; }
        public string? Remark { get; set; }
    }

    public class CreateWorkOrderAttachmentDto
    {
        public string FileName { get; set; } = string.Empty;
        public string FileType { get; set; } = string.Empty;
        public string FileUrl { get; set; } = string.Empty;
        public string? Uploader { get; set; }
        public DateTime? UploadTime { get; set; }
        public string? Remark { get; set; }
    }
}
